import { Modal } from 'antd'
import { ForwardedRef, forwardRef, ForwardRefRenderFunction, useImperativeHandle, useState } from 'react'
// import Write from '../../write/write'

const EditModal: ForwardRefRenderFunction<{ showModal: Function }, { search: Function }> = (
  { search },
  childRef: ForwardedRef<{ showModal: Function }>
) => {
  const [isModalVisible, setIsModalVisible] = useState<boolean>(false)
  const showModal = () => {
    setIsModalVisible(true)
  }
  const handleCancel = () => {
    search()
    setIsModalVisible(false)
  }
  useImperativeHandle(childRef, () => ({
    // changeVal 就是暴露给父组件的方法
    showModal
  }))
  return (
    <div>
      <Modal title="编辑" style={{ top: 20 }} width={1000} visible={isModalVisible} footer={null} onCancel={handleCancel}>
        {/* <Write></Write> */}
      </Modal>
    </div>
  )
}
export default forwardRef(EditModal)
